<template>
  <div>
    <el-card style="margin: 15px; min-height: calc(100vh - 111px);" v-loading="loading">
      <div style="display: flex">
        <div style=" margin-left: 30px; position: relative">
          <el-descriptions :column="1" :size="large" border title="用户信息" v-show ="identity === 'student'">
            <el-descriptions-item>
              <template slot="label">
              <i class="el-icon-user"></i>
                姓名
              </template>
              {{ userList.name }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                  学号
              </template>
              {{ userList.studentId }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                  性别
              </template>
              {{ userList.gender }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                  年龄
              </template>
              {{ userList.age }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                  所属宿舍
              </template>
              {{ userList.dormName }}
            </el-descriptions-item>
          </el-descriptions>
          <el-descriptions :column="1" :size="large" border title="用户信息" v-show ="identity === 'admin'">
            <el-descriptions-item>
              <template slot="label">
              <i class="el-icon-user"></i>
                账户
              </template>
              {{ userList.account }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                创建时间
              </template>
              {{ userList.createTime }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                修改时间
              </template>
              {{ userList.updateTime }}
            </el-descriptions-item>
          </el-descriptions>
        </div>
      </div>
    </el-card>
  </div>
</template>

<script>
import { getSelfInfo} from "@/api/self";
export default {
  name: "SelfInfo",
  data(){
    return{
      userList: [],
      identity: "",
      loading: true,
      open: false, // 控制对话框的显示与隐藏
    };
  },
  methods: {
  },
  created(){
    getSelfInfo().then((response) => {
      this.userList = response.data.data.user;
      this.identity = response.data.data.identity;
      this.loading = false
    });
  },
}
</script>

<style>

</style>